package com.keyidea.jfxui.core.system;

import cn.hutool.core.bean.BeanUtil;
import com.keyidea.jfxui.core.page.TableDataInfo;
import com.keyidea.jfxui.core.system.domain.AjaxResult;
import com.keyidea.jfxui.core.system.sqlite.entity.SysOperLog;
import com.keyidea.jfxui.core.system.sqlite.mapper.SysOperLogMapper;
import com.keyidea.jfxui.core.util.Convert;
import feign.Param;
import feign.QueryMap;
import feign.RequestLine;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
@RequiredArgsConstructor
public class SysOperlogService extends BaseService {

    private final SysOperLogMapper sysOperLogMapper;

    public TableDataInfo list(@QueryMap Map<String, Object> map) {
        SysOperLog operLog = BeanUtil.toBean(map, SysOperLog.class);
        startPage(map);
        List<SysOperLog> list = sysOperLogMapper.selectOperLogList(operLog);
        return getDataTable(list);
    }

    public void export(SysOperLog operLog) {
//        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
//        ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
//        util.exportExcel(response, list, "操作日志");
    }

    public AjaxResult remove(@Param("operIds") String operIdsStr) {
        Long[] operIds = Convert.toLongArray(operIdsStr);
        return toAjax(sysOperLogMapper.deleteOperLogByIds(operIds));
    }

    public AjaxResult clean() {
        sysOperLogMapper.cleanOperLog();
        return success();
    }

    public AjaxResult add(SysOperLog operLog) {
        sysOperLogMapper.insertOperlog(operLog);
        return success();
    }
}
